package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.Vote;

/**
 * 
 * @author 
 *
 */
@DAO
public interface VoteDAO{
	
	@SQL("SELECT * FROM vote WHERE deleteFlag=1 #if(:t.descs!=''){AND descs like '%##(:t.descs)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<Vote> query(@SQLParam("t") Vote vote);
	
	@SQL("SELECT count(*) FROM vote WHERE deleteFlag=1 #if(:t.descs!=''){AND descs like '%##(:t.descs)%' } ")
    int querysize(@SQLParam("t") Vote vote);
    
    @SQL("select * from vote where id=:1")
    Vote queryById(int id);
    
    @SQL("INSERT INTO vote (isLogin,descs,voteStart,voteEnd,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES (:t.isLogin,:t.descs,:t.voteStart,:t.voteEnd,1,:t.createUser,now(),:t.updateUser,now())")
    void create(@SQLParam("t") Vote vote);
	
	@SQL("UPDATE vote SET isLogin=:t.isLogin,descs=:t.descs,voteStart=:t.voteStart,voteEnd=:t.voteEnd,updateUser=:t.updateUser,updateAt=now() WHERE id=:t.id")
    void update(@SQLParam("t") Vote vote);
    
    @SQL("UPDATE vote SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);

    @SQL("select id,descs from vote where deleteFlag=1 and voteEnd > NOW()")
	List<Map> vldtVote();
}